<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<title>极速原箱转运</title>
		<link rel="stylesheet" type="text/css" href="btn_class.css" />
		<link rel="stylesheet" type="text/css"
			href="ext-2.2/resources/css/ext-all.css" />
		<link rel="stylesheet" type="text/css"
			href="ext-2.2/ext-2.2/style.css" />
		<link rel="stylesheet" type="text/css"
			href="ext-2.2/ext-2.2/desktop.css" />
		<link rel="stylesheet" type="text/css"
			href="ext-2.2/ext-2.2/ext-patch.css" />

		<script type="text/javascript" src="ext-2.2/adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="ext-2.2/ext-all.js"></script>
		<script type="text/javascript" src="js/util.js"></script>
		<script type="text/javascript" src="js/cal.js"></script>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

		<script type="text/javascript"><!--
		<%String uId = (String) session.getAttribute("Uid");
			if (uId == null || uId.equals("null")) {%>
			window.parent.location.href = 'index.jsp';
		<%}%>

		//简单的根据class找元素
		function getByClass(oParent,sClass){
		     var aEle=oParent.getElementsByTagName('tr');
 		     var aResult=[];
   		     var i=0;
		     for(i=0; i<aEle.length; i++){
	          if(aEle[i].className==sClass){aResult.push(aEle[i])}
		     }
		     return aResult;
		}
		
		function showEnterWaybillListDiv(){
			var wbWarehouse = document.getElementById("wbWarehouse").value;
			if(wbWarehouse != ""){
				//根据选择的仓库,来选择性的显示中国的口岸
				if(wbWarehouse == "CA")
				{
					removeAll("wbKouAn");
					addOption("wbKouAn","成都","BJ");
					addOption("wbKouAn","天津","TJ");
					addOption("wbKouAn","上海(经济)","SHJJ");
					addOption("wbKouAn","上海普货(包税)","SHBS");
					addOption("wbKouAn","上海包税电子产品","SHBSDZ");
					addOption("wbKouAn","上海特殊类电子产品(手机、电脑)","SHPC");
					addOption("wbKouAn","上海其他","SHQT");		
					chageTip();					
				}
				if(wbWarehouse == "OR")
				{
					removeAll("wbKouAn");
					addOption("wbKouAn","成都","BJ");
					addOption("wbKouAn","天津","TJ");
					addOption("wbKouAn","上海(经济)","SHJJ");
					addOption("wbKouAn","上海普货(包税)","SHBS");
					addOption("wbKouAn","上海包税电子产品","SHBSDZ");
					addOption("wbKouAn","上海特殊类电子产品(手机、电脑)","SHPC");
					addOption("wbKouAn","上海其他","SHQT");
					chageTip();				
				}
				if(wbWarehouse == "NK")
				{
					removeAll("wbKouAn");
					//addOption("wbKouAn","上海(包税)","SHBS");
					addOption("wbKouAn","福州","FZ");		
					chageTip();					
				}
			}else{
				removeAll("wbKouAn");
			}
		}
	
		 function clearNoNum(obj)
		    {
		        //先把非数字的都替换掉，除了数字和.
		        obj.value = obj.value.replace(/[^\d.]/g,"");
		        //必须保证第一个为数字而不是.
		        obj.value = obj.value.replace(/^\./g,"");
		        //保证只有出现一个.而没有多个.
		        obj.value = obj.value.replace(/\.{2,}/g,".");
		        //保证.只出现一次，而不能出现两次以上
		        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
		    }
			
		function customerSubmitWaybill(){
			if(document.getElementById("wbWarehouse").value==""){
				alert("请选择仓库！");
				return;
			}
			//填写货物说明
			if(document.getElementById("wbGoodsDesc").value==""){
				alert("请填写货物说明！");
				return;
			}
			
			//校验美国运单号和预估重量
			var wbUps = document.getElementById("wbUps").value;
			var wbEnterWeight = document.getElementById("wbEnterWeight").value;
			var regu =/^[A-Za-z0-9]+$/;
			var re = new RegExp(regu); 
			if (!re.test(wbUps)) { 
				alert("请输入正确的美国运单号,只允许字母和数字!");
				return; 
			}
			
			if(wbUps=="")
			{
				alert("美国运单号不能为空!");
				return;
			}
			if(wbEnterWeight=="")
			{
				alert("预估重量不能为空!");
				return;
			}

			var wbEstimatedCost = document.getElementById("wbEstimatedCost").value;
			if(wbEstimatedCost=="")
			{
				alert("预估费用不能为空!");
				return;
			}

			var accoutMoney = "<c:out value= '${integralTO.accoutMoney}'/>";
			//alert(accoutMoney);
			//alert(wbEstimatedCost);
			if(FloatSub(accoutMoney,wbEstimatedCost)<0)
			//if(wbEstimatedCost>accoutMoney)
			{
				alert("对不起,余额不足,请先充值!");
				return;
			}
			//请填写申报价值
			if(document.getElementById("wbApplyValue").value==""){
				alert("请填写申报价值！");
				return;
			}
			
			//下面是javascript获取单选框
			var sel = 0; 
			for (var i = 0; i < document.getElementsByName("wbOperateRequireType").length; i++) 
			　{ 
			  　　if(document.getElementsByName("wbOperateRequireType")[i].checked) {
			   　　　　sel = document.getElementsByName("wbOperateRequireType")[i].value; }
			　} 
		
			//收获地址选择的情况
			var choseAddressLen=0;
			var addr = document.getElementsByName("wbAddressList");
			for(var i=0;i<addr.length;i++){
				if(addr[i].checked){
					choseAddressLen++;
				}
			}
			
			//如果是基本服务,只可以选择一个运单号和一个地址
			if(sel==0){
					if(choseAddressLen!=1){
					alert("极速原箱可以选择一个收货地址!");
					return;
				}
			}

	   		 Ext.Ajax.request({ 
	             //请求地址 
	             url: 'waybill!checkWaybillExist.do', 
	             //提交参数组 
	             params: { 
	                 wbUps : Ext.get('wbUps').dom.value.trim()
	             }, 
	             //成功时回调 
	             success: function(response, options) { 
	                //获取响应的json字符串 
	               var responseArray = Ext.util.JSON.decode(response.responseText);                                               
	                    if(responseArray.success==true){ 
	        				var f = document.forms["customerSubmitWaybillForm"];
	        				f.action = "waybill!customerSubmitNewWaybill.do?wbIsFastBox=Y";
	        				f.submit();
	                    } 
	                    else{ 
	                    	alert("对不起,该快递号已经存在!");
	    			   		return;
	                    } 
	            } 
	   		 });
	
			
		}
		function setIntegral(){
			Ext.Ajax.request({ 
                   //请求地址 
                   url: 'integral!getIntegralPoint.do?Uid=<%=session.getAttribute("Uid")%>', 
                   //成功时回调 
                   success: function(response, options) { 
                      //获取响应的json字符串 
                      
                     var responseArray = Ext.util.JSON.decode(response.responseText);    
                          if(responseArray.success==true){ 
                          	var point =  responseArray.point;
                          	if(point<=0 || point == undefined){
                          		document.getElementById("wbIsIntegral").disabled = "disabled";
                          	}
                         	document.getElementById("integralNum").innerHTML = point;
                          } 
                	  } 
          	}); 
		}

		function chageTip(){
			var v = document.getElementById("wbKouAn").value;
			var w = document.getElementById("wbWarehouse").value;
			var tip = document.getElementById("messageId");
			if(v == "BJ") tip.innerHTML = "4.5美金/磅";
			if(v == "GZ") tip.innerHTML = "5美金/磅";
			if(v == "GZBS") tip.innerHTML = "6美金/磅";
			if(v == "SHPC")
			{
				 tip.innerHTML = "上海特殊类电子产品,高档手机、手提电脑、新苹果、ipad,价格6美金/磅,首重10,续重6";
				 document.getElementById("integral").style.display  = 'none';
			}else if(v == "SHBS")
			{
				 tip.innerHTML = "上海普货包税线,价格6美金/磅";
				 document.getElementById("integral").style.display  = 'none';
			}else if( v=="SHBSDZ" ){
				tip.innerHTML = "上海电子化妆品等,首重8,续重6";
				 document.getElementById("integral").style.display  = 'none';
			}else if( v=="SHJJ" ){
				tip.innerHTML = "上海经济线，4.5美金1磅，无首重";
				 document.getElementById("integral").style.display  = 'none';
			}else if( v=="SHQT" ){
				tip.innerHTML = "上海其他类,钻石、项链等,首重12,续重10";
				 document.getElementById("integral").style.display  = 'none';
			}
			else if(v == "FZ")
			{
				tip.innerHTML = "5美金/磅";
				document.getElementById("integral").style.display  = 'none';
			}else if(v == "TJ"){
				tip.innerHTML = "首重5.5美金/磅,续重4.5美金/磅,注意:不能发电子产品";
				document.getElementById("integral").style.display  = 'none';
			}
			else{
				document.getElementById("integral").style.display  = '';
			}
		}
		window.onload = function(){
			if( "<%=request.getAttribute("customerSubmitFlag")%>"=="SUCCESS")
			{
				alert("订单提交成功！");
			}
			//window.parent.left.location.reload(); 
			setIntegral();
		}
	--></script>
	<style type="text/css">
		input
		{
			padding-bottom : 0px;
			margin : 0px;
			padding-left : 0px;
			padding-right : 0px;
			font-family : "宋体", Arial, Helvetica, sans-serif;
			font-size : 12px;
			padding-top : 0px;
			height : 90px;
		}
		.inputradio
		{
			padding-bottom : 0px;
			margin : 0px;
			padding-left : 0px;
			padding-right : 0px;
			font-family : "宋体", Arial, Helvetica, sans-serif;
			font-size : 12px;
			padding-top : 0px;
			height : 12px;
		}
		.btnSubmit
		{
			padding-bottom : 0px;
			margin : 0px;
			padding-left : 0px;
			padding-right : 0px;
			font-family : "宋体", Arial, Helvetica, sans-serif;
			font-size : 12px;
			padding-top : 0px;
			height : 18px;
		}
		div
		{
			padding-bottom : 0px;
			margin : 0px;
			padding-left : 0px;
			padding-right : 0px;
			font-family : "宋体", Arial, Helvetica, sans-serif;
			font-size : 12px;
			padding-top : 0px;
			
		}
		.right_center
		{
			background : white;
			padding-bottom: 50px;
			padding-left: 30px;
			width : 100%;
			padding-right: 0px;
			padding-top: 28px;
		}
		.wenzi
		{
			text-align : right;
			line-hight :20 px;
			width :102px;
			padding-right :10px;
			float : left;
			height :20 px;
		}
		.wenzi2
		{
			text-align : right;
			line-hight :18 px;
			width :100px;
			float : left;
			height :75 px;
		}
		
		.bd1
		{
			width : 200px;
			float : left;
			height : 20px;
		}
		.wwhh
		{
			padding-bottom : 10px;
			line-height : 14px;
			padding-left : 110px;
			width : 1000px;
			padding-right : 0px;
			color : #a9a9a9;
			padding-top : 0px;
		}
		.pd1
		{
			padding-left : 10px;
		}
	
		.bd3
		{
			width : 13px;
			height : 13px;
		}
		.bd4
		{
			margin : 0px 5px;
			width : 40px;
			height : 15px;
		}
		.bd5
		{
			width : 80px;
			height : 15px;
		}
		.bd6
		{
			width : 582px;
			height : 88px;
		}
		.pd5
		{
			line-height : 18px;
			padding-left : 176px;
			padding-top : 10px;
		}
		.tdCss
		{
			padding-bottom:0px;
			margin:0px;
			padding-left : 0px;
			padding-right:0px;
			font-family: "宋体", Arial, Helvetica, sans-serif;
			font-size : 12px;
			padding-top : 0px;
		}
	</style>
	</head>


<body class="ext-ie ext-ie6 ext-border-box " id="ext-gen6">
<div class="x-panel x-panel-noborder x-form-label-right" id="ext-comp-1001" style="width: 100%;">
	<div class="x-panel-header x-panel-header-noborder x-unselectable" id="ext-gen8" style="mozuserselect: none; khtmluserselect: none;" unselectable="on">
		<span class="x-panel-header-text" id="ext-gen21">极速原箱转运</span>
	</div>
	<p><font style="color:red;font-size:15px;font-weight:bold;">&nbsp;&nbsp;&nbsp;一：如果货物已经在我公司仓库，而且入库到您的账户里了。　请用＂到货库件＂里填写运单提交即可</font></p>
	<p><font style="color:red;font-size:15px;font-weight:bold;">&nbsp;&nbsp;&nbsp;二：如果您已经从网站下单，而且有了美国境内的运输单号，但是还没有入库。您可以使用极速原箱转运功能。</font></p>
	
	 <form name="customerSubmitWaybillForm" method="post">
		<div class="right_center">
			<div style="height:26px">
				<div class="wenzi">选择仓库</div>
				<select name="wbWarehouse" id="wbWarehouse" class="bd1" onchange ="showEnterWaybillListDiv();">
					<option value="" >请选择货物所在仓库</option>
					<option value="CA" >CA 地址</option>
					<option value="OR" >OR 地址</option>
					<option value="NK" >New York 地址</option>
				</select><font style="color:red;font-weight:bold;">*</font>
			</div>
			<br/>
			<div class="hn">
				<div class="wenzi">货物说明：</div>
				<textarea name="wbGoodsDesc" id="wbGoodsDesc" class="bd6" rows="5" cols="50"></textarea>
				<p class="wwhh"><font color="#ff0000">请如实填写，如海关抽查到描述不符，可能被没收!如：鞋子5双、剃须刀2个、电动玩具1个</font></p>
			</div>
			<div style="height:26px">
				<div class="wenzi">美国快递单号：</div>
				<input name="wbUps" class="bd1" type="text" size="18" /><font color="#ff0000">*</font>
				<p class="wwhh"><font color="#ff0000" style="font-weight:bold">实际到货号码必须与此号码必须确保100%完全匹配，才能激活极速原箱。</font></p>
			</div>
			<div style="height:26px">
				<div class="wenzi">预估重量：</div>
				<input name="wbEnterWeight" class="bd1" type="text" size="18" onkeyup="clearNoNum(this)" id="wbEnterWeight"/><font color="#ff0000">Lbs* </font>
				<p class="wwhh"><font color="#ff0000" style="font-weight:bold">我们会按照实际重量进行收费发货.</font></p>
			</div>
			<div style="height:26px">
				<div class="wenzi">预估费用：</div>
				<input name="wbEstimatedCost" class="bd1" type="text" size="18" onkeyup="clearNoNum(this)" id="wbEstimatedCost"/><font color="#ff0000">RMB* </font>
				您现在的余额:  <font style="color:red"><c:out value= "${integralTO.accoutMoney}"/></font>&nbsp;RMB
			</div>
			<div style="height:26px">
				<div class="wenzi">申报价值：</div>
				<input name="wbApplyValue" class="bd1" type="text" size="18" onkeyup="value=value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')"/>
				<span class="pd1">美金</span>
				<span class="pd1">需要购买保险（3%申报价值）</span>
				<input name="wbInsuranceFlag" class="bd3" type="checkbox" value="Y"/>
			</div>
				<div style="height:26px">
				<div class="wenzi"><font style="color:red">选择口岸：</font></div>
				<select name="wbKouAn" id="wbKouAn" class="bd1" onchange="chageTip()">
					<!-- <option value="BJ" >北京</option> -->
					<!--  <option value="BJ" >成都</option>-->
					<!-- 
						<option value="GZ" >广州</option>
						<option value="GZBS" >广州(包税)</option>
						 -->
						<!-- <option value="SHBS" >上海(包税)</option>
						<option value="SHBSDZ" >上海包税电子产品</option> -->
					<!--<option value="TJ" >天津</option>-->
					<!-- <option value="CQ" >重庆</option> -->
				</select>
				<span class="pd1" id="messageId" style="color:red"></span>
			</div>
			
			<div class="hn">
				<div class="wenzi">操作要求：</div>
				<div style="height:26px">
					<label style="height:30px">
						<input name="wbOperateRequireType" id="wbOperateRequireType1" type="radio" checked="checked" value="0" class="inputradio" />
						基本服务 极速原箱;
					</label>
				</div>
			</div>
			<div style="height:26px">
				<div class="wenzi">包装要求：</div>
				<div style="height:26px">
					<label style="height:30px">
						取出发票
						<input name="wbPackqcfp"  type="checkbox"  value="1" class="inputradio"/>
						加急处理
						<input name="wbPackjjcl"  type="checkbox"  value="1" class="inputradio"/>
						内件加固
						<input name="wbPacknjjg"  type="checkbox"  value="1" class="inputradio"/>
						更换外箱
						<input name="wbPackghwx"  type="checkbox"  value="1" class="inputradio"/>
						加套外箱
						<input name="wbPackjtwx"  type="checkbox"  value="1" class="inputradio"/>
						去除内件
						<input name="wbPackqcnj"  type="checkbox"  value="1" class="inputradio"/>
						原箱转发
						<input name="wbPackyxzy"  type="checkbox"  value="1" class="inputradio"/>
						指定物品分箱
						<input name="wbPackzdwpfx"  type="checkbox"  value="1" class="inputradio"/>
					</label>
				</div>
			</div>
			<div style="height:26px;display:''" id="integral">
				<div class="wenzi">用积分抵扣：</div>
				<input name="wbIsIntegral" class="bd3" id="wbIsIntegral" type="checkbox" value="Y" />
				<span class="pd1">我目前的积分：<span style="color:red" id="integralNum"></span></span>
			</div>
			<div class="hn">
				<div class="wenzi">备注说明：</div>
				<textarea name="wbNote" class="bd6" rows="5" cols="50"></textarea>
			</div>
				  
			
			<div style="line-height:26px;padding-left:48px;height:26px;padding-top:5px;">
			请填写运单内容并核对，详尽正确的货物描述信息是准确操作的重要保障！
			</div>
			<div style="height:40px"></div>
			
			<div style="line-height : 26px;padding-left : 48px;">
				<table width="700" border="1" cellSpacing="1" cellPadding="0"  style="border-collapse:collapse;" >
				<tr>
					<td colspan="4" align="center"><font color="#ff0000">收货地址选择</font></td>
				</tr>
				<s:iterator id="addr" value="addressList">
				<tr>
					<td width="40" align="center">
						<input name="wbAddressList" class="bd3" type="checkbox" valign="top" value="<s:property value="#addr.PUaddrId"/>" />
					</td>
					<td width="100" class="tdCss" align="center">
						<s:property value="#addr.PUname" />	
					</td>
					<td width="100" class="tdCss">
						<s:property value="#addr.PUphoneNum" />	
					</td>
					<td width="*"  class="tdCss">
						<s:property value="#addr.PUarea" />---<s:property value="#addr.PUaddress" />
					</td>
				<tr>
				</s:iterator>
				</table>
				
			</div>
			
			
			<div style="line-height:10px;padding-left:50px;padding-top:18px;" >			
				<input type="button" value="提交运单" class="btnSubmit" onclick="customerSubmitWaybill()" />
			</div>
			
		</div>
	</form>
</div>
</body>

</html>

